package cn.craftyun.serverlist.vo;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * 结果实体类
 *
 * @param <T> 返回Data类型
 */
@Data
@AllArgsConstructor
public class ResultEntity<T> {
    /**
     * 返回码
     */
    private Integer code;
    /**
     * 提示信息
     */
    private String message;
    /**
     * 数据
     */
    private T data;

    public static <T> ResultEntity<T> success(String message, T data) {
        return new ResultEntity<>(200, message, data);
    }

    public static <T> ResultEntity<T> success(String message) {
        return success(message, null);
    }

    public static <T> ResultEntity<T> failed(String message, T data) {
        return new ResultEntity<>(500, message, data);
    }

    public static <T> ResultEntity<T> failed(String message) {
        return failed(message, null);
    }
}
